package com.example.demo.controller.impor;

import cn.hutool.json.JSONUtil;
import com.example.demo.dbo.User;
import com.example.demo.util.HttpClientUtils;
import com.example.demo.util.JsonUtil;

import java.time.DayOfWeek;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class TestUU {

    public static void main(String[] args) {

        maxxx(1);
        List<User> list = new ArrayList<>();
        List<User> list2 = Collections.EMPTY_LIST;
        List<String> ids = list2.stream()
                .map(User::getUserId)
                .collect(Collectors.toList());

        User user = new User();
        user.setUserId("111");
        user.setName("张三");
        user.setAge(1);

        User user2 = new User();
        user2.setUserId("111");
        user2.setName("李四");
        user2.setAge(1);

        User user3 = new User();
        user3.setUserId("222");
        user3.setName("王五");
        User user4 = new User();
        user4.setUserId("111");
        user4.setName("里斯");
        user4.setAge(1);
        list.add(user);
        list.add(user2);
        list.add(user3);
        list.add(user4);
        System.out.println(JSONUtil.toJsonStr(list));
        Map<String, List<User>> map = list.stream().collect(Collectors.groupingBy(User::getUserId,Collectors.toCollection(ArrayList::new)));
        for (User job : list) {
            if (map.containsKey(job.getUserId())){
                System.out.println(map.get(job.getUserId()).get(0).getName());
            }
        }
        System.out.println(map);

//        long a = 217364878822l;
//        long b = 1024*3;
//        System.out.println(a/b);
//        System.out.println(getLastFriday1800());

//        String videoUrl = "http://192.168.1.1:8080/video/1.mp4";
//        String capture = "http://192.168.1.1:8080/video/1.jpg";
//        String videoInfo = "<contentvideo><video name=\"NAME\"><![CDATA[showPlayer({videoInfo: [{src:'"+videoUrl+"',type:'video/mp4',label:'源视频',}],posterUrl:'"+capture+"',width: 800,height: 495,type: 1});]]></video></contentvideo>";
//
//        System.out.println(videoInfo);
//
//        User user= new User();
//        user.setName(null);
//        user.setUserId("111");
////        System.out.println(JSONUtil.toJsonStr(user));
//        user.setTranscodeTemplateIds(new ArrayList<>());
////        speak(user);
//        user.setAge(1);
//        if (user.getAge() !=0) {
//            System.out.println(user.getAge());
//        }
    }

    private static void maxxx(int i) {
        if (true) {
            System.out.println("我是yes");

            return;
        }
        System.out.println("我是no");
    }

    public static String getLastFriday1800() {
        // 获取当前日期时间
        LocalDateTime now = LocalDateTime.now();

        // 计算上周周五 18:00:00 的时间点
        LocalDateTime lastFriday = now.minusWeeks(0)
                .with(TemporalAdjusters.previousOrSame(DayOfWeek.FRIDAY))
                .withHour(18)
                .withMinute(0)
                .withSecond(0)
                .withNano(0);

        // 定义日期时间格式化器
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        // 将 LocalDateTime 格式化为字符串
        return lastFriday.format(formatter);
    }
//
//    private static void speak(User user) {
//
////        HttpClientUtils.postJson("http://localhost:8888/getUU",JsonUtil.toJson(user));
//        System.out.println(user);
//    }
}
